﻿using KAsFrame.Application.Contracts.Certificate;
using KAsFrame.Common.Const;
using KAsFrame.Common.Controllers;
using KAsFrame.Common.Dto;
using KAsFrame.Domain.Certificate.Dto;
using KAsFrame.Domain.Certificate.Entities;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace KAsFrame.Application.Controller.Certificate
{
    [Route(ConstConfig.ApiRouteConfig)]
    [ApiController]
    public class CertificateController : CommonCurdController<long, CertificateInfo, CertificateCreateDto, CertificateCreateDto, CertificateDto>
    {
        private new readonly ICertificateAppService _appService;

        public CertificateController(ICertificateAppService appService) : base(appService)
        {
            _appService = appService;
        }

        [HttpGet]
        [AllowAnonymous]
        public async Task<ApiResult<CertificateInfoDto>> GetInfoAsync(long certificateNo)
        {
            var result = ApiResult<CertificateInfoDto>.IsSuccess();
            result.Data = await _appService.GetInfoAsync(certificateNo);
            return result;
        }
    }
}
